package com.gjt.controller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created with Intel IDEA.
 * Oracle
 * @Auther: gjt
 * @Date: 2024/4/2 12:50
 */
public class JdbcOracle {

    private static final String URL  ="jdbc:oracle:thin:@localhost:1521:ORCL" ;
    private static final String USERNAME  ="C##SA" ;
    private static final String PASSWORD  ="123456" ;

    public static  Connection getConnection() throws ClassNotFoundException, SQLException {


        //1: 导入jar 包
        //2：注册驱动
        Class.forName("oracle.jdbc.driver.OracleDriver") ;

        //3：获取数据库连接对象
        Connection connection = DriverManager.getConnection(URL,USERNAME,PASSWORD);

        System.out.println(connection);
        return connection;
    }

    public static void main(String[] args) throws SQLException, ClassNotFoundException {

        Connection connection = getConnection();
    }

}
